﻿/**
 * ...
 * @author wangjun
 */
class A2.io.Tab 
{ 
	var oid:Number; 
	var num;
	var max:Number;
	public function Tab(arr:Array,stt) 
	{   
		var max = arr.length-1;
		if (stt.constructor == TextField) Selection.setFocus(stt);
		else if (stt.constructor == Number && stt < arr.length) Selection.setFocus(arr[stt]);
		var listener:Object = { }
		listener.onKeyDown = function() { 
			if (Key.getCode() == Key.TAB) { 
				var temparr:Array 	= Selection.getFocus ().split('.') ;
				var name:String = temparr[temparr.length-1] 
				for (var i:Number = 0; i <arr.length ; i++) 
				{
					//trace(arr[i]._target)
					//trace('judge '+(name == arr[i]._name));
					if (name == arr[i]._name) {
						var nid:Number = i;
					}
					
				} 
				trace('nid: '+nid)
				if (nid == null) {
					nid = 0;
				}
				if (nid == max) {
					nid = 0;
				}else {
					nid ++;
				}  
				trace('nid: '+nid)
				Selection.setFocus(arr[nid]) 
				trace('dangqian '+arr[nid])
				oid = nid ;
			}  
		};
		Key.addListener(listener);  
	}
	
}